import http from "@/api/config/http";
import { IQuery, IResponse, ITableResponse } from "@/types/http/IAxios";
import { NewStation, Station } from "./types";
// 查询基站管理列表
export function listStation(query?: IQuery): Promise<ITableResponse<Station>> {
  return http.request({
    url: "/station/station/list",
    method: "get",
    params: query
  });
}

// 查询基站管理列表
export function queryStation(): Promise<ITableResponse<Station>> {
  return http.request({
    url: "/station/station/query",
    method: "get"
  });
}

// 删除基站管理
export function delStation(stationId: Array<string>) {
  return http.request({
    url: `/station/station/${stationId}`,
    method: "delete"
  });
}

// 新增基站管理
export function addStation(data: Station) {
  return http.request({
    url: "/station/station",
    method: "post",
    data
  });
}

export function getStationNews(): Promise<IResponse<Array<NewStation>>> {
  return http.request({
    url: "/station/station/news",
    method: "get"
  });
}

export function updateStation(data: Station) {
  return http.request({
    url: "/station/station",
    method: "put",
    data
  });
}

/* 更新硬件 */
export function upgradeStation(data: any) {
  return http.request({
    url: "/station/station/upgrade",
    method: "post",
    data
  });
}
/* 查询基站下的所有列表 */
export function manageList(query: IQuery) {
  return http.request({
    url: "/v2/station/manage/list",
    method: "get",
    params: query
  });
}

export const recoverStation = (data: string[]) => {
  return http.request({
    url: "/station/station/recover",
    method: "post",
    data
  });
};

interface Translate {
  list: string[];
  to: string;
}
export const shiftStation = (data: Translate) => {
  return http.request({
    url: "/station/station/shift",
    method: "post",
    data
  });
};

export const shiftStationByStore = (from: string, to: string) =>
  http.request({
    url: `/station/station/shift`,
    method: "get",
    params: {
      from,
      to
    }
  });
